package com.wiscamp.ninechapters.problems.infrastructure.po.problems;

import com.wiscamp.ninechapters.ddd.PersistenceObject;
import com.wiscamp.ninechapters.problems.enums.Actions;
import jakarta.persistence.*;
import lombok.Data;

import java.io.Serial;
import java.util.ArrayList;
import java.util.Collection;

/**
 * 问题
 */
@Table(name = "questions_view")
@Entity
@Data
public class QuestionView implements PersistenceObject {

    @Serial
    private static final long serialVersionUID = -3872618859689346837L;

    /**
     * 问题编号
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "question_id", insertable = false, nullable = false)
    private long questionId = 0;

    /**
     * 题编号
     */
    @Column(name = "problem_id", nullable = false)
    private long problemId = 0;

    /**
     * 题型编号
     */
    @Column(name = "problem_type_id", nullable = false)
    private long problemTypeId = 0;

    /**
     * 问题类型编号
     */
    @Column(name = "question_type_id", nullable = false)
    private long questionTypeId = 0;

    /**
     * 问题超文本内容
     */
    @Column(name = "question_hypertext")
    private String questionHypertext = "";

    /**
     * 问题翻译
     */
    @Column(name = "question_translation")
    private String questionTranslation = "";

    /**
     * 答题时间限制
     */
    @Column(name = "time_limit", nullable = false)
    private int timeLimit = 0;

    /**
     * 问题分数
     */
    @Column(name = "question_score", nullable = false)
    private int questionScore = 0;

    /**
     * 高亮文本
     */
    @Column(name = "highlight_text")
    private String highlightText = "";

    /**
     * 难度
     */
    @Column(name = "difficulty")
    private int difficulty = 0;

    /**
     * 问题序号
     */
    @Column(name = "question_index")
    private int questionIndex = 0;

    /**
     * 是否需要解题步骤
     */
    @Column(name = "need_steps")
    private boolean needSteps = false;

    @Column(name = "problem_type_name")
    private String problemTypeName = "";

    @Column(name = "question_type_name")
    private String questionTypeName = "";

    @Transient
    private Collection<QuestionOptionPO> options = new ArrayList<>();

    @Transient
    private Collection<QuestionAnswerPO> answers = new ArrayList<>();

    @Transient
    private Collection<QuestionSolutionPO> solutions = new ArrayList<>();

    @Transient
    private Actions action = Actions.NONE;
}